package org.dtrd.modules.record.entity.bean;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.record.entity.po.DtrdEntRdSigninNutrientRecord;

import java.util.Date;

/**
 * 营养素记录
 *
 *
 * @author QR
 * @since 2021-12-06
 */
@Data
@ApiModel(value = "DtrdEntRdSigninNutrientRecord数据传输对象", description = "营养素记录")
public class NutrientRecordInfo {

    @ApiModelProperty()
    private Integer dataId;

    @ApiModelProperty()
    private Integer patientId;

    @ApiModelProperty("营养素Id")
    private Integer nutrientId;

    @ApiModelProperty("使用营养素时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date recordTime;

    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    private Date recordDate;

    @ApiModelProperty("照片以 竖线 | 拼接")
    private String nutrientRecordPhoto;

    @ApiModelProperty("使用营养素描述")
    private String nutrientRecordDescribe;

    @ApiModelProperty("1-早,2-午,3-晚,4-睡前")
    private Integer nutrientRecordType;

    @ApiModelProperty("营养素规格")
    private String nutrientSpec;

    @ApiModelProperty("用法用量")
    private String nutrientUseMode;

    @ApiModelProperty("备注")
    private String nutrientRecordRemark;

    public NutrientRecordInfo() {}

    public NutrientRecordInfo(Integer patientId, Date date, String photo, String desc, Constant.NutrientRecordType type) {
        this.patientId = patientId;
        this.recordTime = date;
        this.nutrientRecordPhoto = photo;
        this.nutrientRecordType = type.getType();
        this.nutrientRecordDescribe = desc;
    }

    public NutrientRecordInfo parseFromPo(DtrdEntRdSigninNutrientRecord po) {
        dataId = po.getDataId();
        patientId = po.getPatientId();
        nutrientId = po.getNutrientId();
        recordTime = po.getRecordTime();
        recordDate = po.getRecordDate();
        nutrientRecordPhoto = po.getNutrientRecordPhoto();
        nutrientRecordDescribe = po.getNutrientRecordDescribe();
        nutrientRecordType = po.getNutrientRecordType();
        nutrientSpec = po.getNutrientSpec();
        nutrientUseMode = po.getNutrientUseMode();
        nutrientRecordRemark = po.getNutrientRecordRemark();
        return this;
    }
}
